package com.caldremch.rxretrofit.api.listener;

import android.text.Html;
import android.util.Log;

import com.caldremch.rxretrofit.api.exception.HttpException;

import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

/**
 * Ubuntu 14.04 LTS
 * Created by Caldremch on 2016-11-2 下午6:56
 */

public abstract  class NextCallback<T> {


    /**
     * 订阅时调用
     * @param d
     */
    public void onSubscribe(@NonNull Disposable d){

    }

    /*成功回调后的方法*/
    public abstract void onNext(T t);

    /*缓存回调结果*/
    public void onCacheNext(String string){

    }

    /*失败或者错误方法, 主动调用灵活控制*/
    public void onError(Throwable e){
        if (e instanceof HttpException) {
            HttpException httpException = (HttpException) e;
            Log.e("tag", "code = " + httpException.code + "msg=" + httpException.getMessage());
        }else {
            e.printStackTrace();
        }
    }

    /*取消回调*/
    public void onCancel(){

    }
    /*网络错误回调*/

    /*code不为0*/
    public void onCompleted() {

    }
}
